﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;

namespace yaTDL
{
    /// <summary>
    /// Interaction logic for SettingsPage.xaml
    /// </summary>
    public partial class SettingsPage : Page
    {
        public SettingsPage()
        {
            InitializeComponent();
        }

        private void button_browseFolders_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            dialog.ShowNewFolderButton = true;

            dialog.ShowDialog();

            if (!String.IsNullOrEmpty(dialog.SelectedPath))
            {
                textBox_Backup_BackupDirectory.Text = dialog.SelectedPath;
            }
        }
    }


    public class IntervalSelectionConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is TimeSpan)
            {
                switch ((int)((TimeSpan)value).TotalHours)
                {
                    case 1:
                        return 0;
                    case 24:
                        return 1;
                    case (24 * 7):
                        return 2;
                    default:
                        return -1;
                }

            }
            else
            { return -1; }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch ((int)value)
            {
                case 0:
                    return new TimeSpan(1, 0, 0);
                case 1:
                    return new TimeSpan(24, 0, 0);
                case 2:
                    return new TimeSpan((24 * 7), 0, 0);
                default:
                    return new TimeSpan(0, 15, 0);
            }
        }
    }
}
